package cn.hchaojie.camp.day05;

import java.util.Timer;
import java.util.TimerTask;

public class DemoTask {
	public static void main(String[] args) {
		Timer timer = new Timer();
		
		TimerTask task = new PrintTask();
		TimerTask printStarTask = new PrintStarTask();

		timer.schedule(task, 0, 1000);
		timer.schedule(printStarTask, 0, 2000);
	}
}

class PrintTask extends TimerTask {
	@Override
	public void run() {
		System.out.println("努力跑任务中。。。。");
	}
}

class PrintStarTask extends TimerTask {
	public void run() {
		for (int y = 2; y >= -2; y--) {
			for (int x = -2; x <= 2; x++) {
				if (x == y || x == -y) {
					System.err.print(" *");
				} else {
					System.err.print(" .");
				}
			}
			
			System.err.println();
		}
	}
}
